package com.yotoodesign.core.common;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Window;

/**
 * 抽象基类Activity
 * @author zhuchuanming
 *
 */
public abstract class BaseActivity extends Activity{
	
	public IGlobalApplication application ;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		application = (IGlobalApplication) getApplication(); 
		application.setActivity(this);
		initContentView();
		initViews();
	}
	
	//抽象方法，用于初始化视图
	public abstract void initContentView();
	public abstract void initViews();
	public abstract void setValues();
	
	public void onDestroy() {		
		super.onDestroy();
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onResume() {
		super.onResume();
		onRefresh();
	}
	public void onRestart() {
		super.onRestart();
	}

	public void onRefresh() {
		setValues();
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return true;
		}
		return false;
	}
	
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		return super.onTouchEvent(event);
	}
	
}
